package com.example.zqm.git72.Activity;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.example.zqm.git72.JavaBean.Club;
import com.example.zqm.git72.Model.ClubModel;
import com.example.zqm.git72.Model.PhotoModel;
import com.example.zqm.git72.R;
import com.squareup.picasso.Picasso;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class WritingActivity extends AppCompatActivity {
private EditText writing;
    private TextView send;
    String userid;
    String title;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_writing);
        writing =(EditText)findViewById(R.id.wirting);
        send=(TextView)findViewById(R.id.send);
        showData();
    }
   public  void  showData(){

       send.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               SharedPreferences sharedPreferences=getSharedPreferences("userInfo", Context.MODE_PRIVATE);
               userid=sharedPreferences.getString("user_id","");
               title=writing.getText().toString();
               PhotoModel photoModel =new PhotoModel();
               Call<String> call = photoModel.fcreate(userid,title);
               call.enqueue(new Callback<String>() {
                   @Override
                   public void onResponse(Call<String> call, Response<String> response) {
                       Toast.makeText(WritingActivity.this,"发表成功！",Toast.LENGTH_SHORT).show();
                   }

                   @Override
                   public void onFailure(Call<String> call, Throwable t) {

                   }
               });
           }
       });




   }
}
